<?php
require_once "includes/config.php";
require_once "includes/functions.php";
if(isset($_GET["addProduct"])) {
  $searchpage = 1;
} else {
  $searchpage = 0;
}
?>
<script src="<?php echo $base_url?>js/jquery-1.4.4.js" type="text/javascript"></script>
<script language="javascript" type="text/javascript">
<?php if($_SESSION['user_type_sess']=="5") { ?>
function click_search_all() // CLICK ON SEARCH ALL
{
   document.getElementById('div_click_search').innerHTML='search all - "searches through local and online listing of products<br />advance search - modifies your area and price range"';
   document.getElementById('srch_all').className = 'selected';
   document.getElementById('srch_local').className = '';
   document.getElementById('srch_online').className = '';
   document.getElementById('srch_merchant').className = '';
   document.getElementById('div_input_search').value='search all';
   document.getElementById('sel_text').innerHTML='search all';
   document.getElementById('sg').value='all';
}
function click_search_local() // CLICK ON SEARCH LOCAL
{
   document.getElementById('div_click_search').innerHTML='search local - "searches through local listings only"';
   document.getElementById('srch_all').className = '';
   document.getElementById('srch_local').className = 'selected';
   document.getElementById('srch_online').className = '';
   document.getElementById('srch_merchant').className = '';
   document.getElementById('div_input_search').value='search local';
   document.getElementById('sel_text').innerHTML='search local';
   document.getElementById('sg').value='local';
}
function click_search_online() // CLICK ON SEARCH ONLINE
{
   document.getElementById('div_click_search').innerHTML='search online - "searches through online listings only"';
   document.getElementById('srch_all').className = '';
   document.getElementById('srch_local').className = '';
   document.getElementById('srch_online').className = 'selected';
   document.getElementById('srch_merchant').className = '';
   document.getElementById('div_input_search').value='search online';
   document.getElementById('sel_text').innerHTML='search online';
   document.getElementById('sg').value='online';
}
function click_search_merchant() // CLICK ON SEARCH MERCHANT
{
   document.getElementById('div_click_search').innerHTML='search for merchant - "searches through merchants only"';
   document.getElementById('srch_all').className = '';
   document.getElementById('srch_local').className = '';
   document.getElementById('srch_online').className = '';
   document.getElementById('srch_merchant').className = 'selected2';
   document.getElementById('div_input_search').value='search for merchant';
   document.getElementById('sel_text').innerHTML='search merchant';
   document.getElementById('sg').value='all';
}

function mouseover_search_all() // MOUSEOVER ON SEARCH ALL
{
   document.getElementById('div_click_search').style.display = 'none';
   document.getElementById('div_click_search2').style.display = '';
   document.getElementById('div_click_search2').innerHTML='search all - "searches through local and online listing of products<br />advance search - modifies your area and price range"';
   document.getElementById('div_input_search').value='search all';
}

function mouseover_search_local() // MOUSEOVER ON SEARCH LOCAL
{
   document.getElementById('div_click_search').style.display = 'none';
   document.getElementById('div_click_search2').style.display = '';
   document.getElementById('div_click_search2').innerHTML='search local - "searches through local listings only"';
   document.getElementById('div_input_search').value='search local';
}

function mouseover_search_online() // MOUSEOVER ON SEARCH ONLINE
{
   document.getElementById('div_click_search').style.display = 'none';
   document.getElementById('div_click_search2').style.display = '';
   document.getElementById('div_click_search2').innerHTML='search online - "searches through online listings only"';
   document.getElementById('div_input_search').value='search online';
}
function mouseover_search_merchant() // MOUSEOVER ON SEARCH MERCHANT
{
   document.getElementById('div_click_search').style.display = 'none';
   document.getElementById('div_click_search2').style.display = '';
   document.getElementById('div_click_search2').innerHTML='search for merchant - "searches through merchants only"';
   document.getElementById('div_input_search').value='search for merchant';
}
function mouseout_to_all_search() // MOUSE OUT ALL
{
   document.getElementById('div_click_search2').style.display = 'none';
   document.getElementById('div_click_search').style.display = '';
}
<?php } else { ?>
function click_search_all()// CLICK ON SEARCH ALL
{
   document.getElementById('div_click_search').innerHTML='search all - "searches through local and online listing of products<br />advance search - modifies your area and price range"';
   document.getElementById('srch_all').className = 'selected';
   document.getElementById('srch_local').className = '';
   document.getElementById('srch_online').className = '';
   document.getElementById('srch_buyer').className = '';
   document.getElementById('div_input_search').value='search all';
   document.getElementById('sel_text').innerHTML='search all';
   document.getElementById('sg').value='all';
}
function click_search_local() // CLICK ON SEARCH LOCAL
{
   document.getElementById('div_click_search').innerHTML='search local - "searches through local listings only"';
   document.getElementById('srch_all').className = '';
   document.getElementById('srch_local').className = 'selected';
   document.getElementById('srch_online').className = '';
   document.getElementById('srch_buyer').className = '';
   document.getElementById('div_input_search').value='search local';
   document.getElementById('sel_text').innerHTML='search local';
   document.getElementById('sg').value='local';
}
function click_search_online() // CLICK ON SEARCH ONLINE
{
   document.getElementById('div_click_search').innerHTML='search online - "searches through online listings only"';
   document.getElementById('srch_all').className = '';
   document.getElementById('srch_local').className = '';
   document.getElementById('srch_online').className = 'selected';
   document.getElementById('srch_buyer').className = '';
   document.getElementById('div_input_search').value='search online';
   document.getElementById('sel_text').innerHTML='search online';
   document.getElementById('sg').value='online';
}
function click_search_buyer() // CLICK ON SEARCH BUYER
{
   document.getElementById('div_click_search').innerHTML='search for buyer - "helps sellers find buyers directly"';
   document.getElementById('srch_all').className = '';
   document.getElementById('srch_local').className = '';
   document.getElementById('srch_online').className = '';
   document.getElementById('srch_buyer').className = 'selected2';
   document.getElementById('div_input_search').value='search for buyer';
   document.getElementById('sel_text').innerHTML='search for buyer';
   document.getElementById('sg').value='buyer';
}

function mouseover_search_all() // MOUSEOVER ON SEARCH ALL
{
   document.getElementById('div_click_search').style.display = 'none';
   document.getElementById('div_click_search2').style.display = '';
   document.getElementById('div_click_search2').innerHTML='search all - "searches through local and online listing of products<br />advance search - modifies your area and price range"';
   document.getElementById('div_input_search').value='search all';
}

function mouseover_search_local() // MOUSEOVER ON SEARCH LOCAL
{
   document.getElementById('div_click_search').style.display = 'none';
   document.getElementById('div_click_search2').style.display = '';
   document.getElementById('div_click_search2').innerHTML='search local - "searches through local listings only"';
   document.getElementById('div_input_search').value='search local';
}

function mouseover_search_online() // MOUSEOVER ON SEARCH ONLINE
{
   document.getElementById('div_click_search').style.display = 'none';
   document.getElementById('div_click_search2').style.display = '';
   document.getElementById('div_click_search2').innerHTML='search online - "searches through online listings only"';
   document.getElementById('div_input_search').value='search online';
}
function mouseover_search_buyer() // MOUSEOVER ON SEARCH BUYER
{
   document.getElementById('div_click_search').style.display = 'none';
   document.getElementById('div_click_search2').style.display = '';
   document.getElementById('div_click_search2').innerHTML='search for buyer - "helps sellers find buyers directly"';
   document.getElementById('div_input_search').value='search buyer';
}
function mouseout_to_all_search() // MOUSEOUT ALL
{
   document.getElementById('div_click_search2').style.display = 'none';
   document.getElementById('div_click_search').style.display = '';
   document.getElementById('div_input_search').value=document.getElementById('sel_text').innerHTML;
}
<?php } ?>
</script>
<script language="javascript" type="text/javascript">
  function show_helpBox()
  {
    var help_pos = $('#help_a').position();
    var new_left = parseInt(help_pos.left);
    var new_top = parseInt(help_pos.top) + 28;
    $('#help_drop_down').css({'left': new_left, 'top':new_top});
    $('#help_drop_down').slideDown('slow');
  }
  
  function show_mySwapenBox()
  {
    var myswap_pos = $('#my_swapen').position();
    var new_left = parseInt(myswap_pos.left);
    var new_top = parseInt(myswap_pos.top) + 28;
    $('#div_myswapen').css({'left': new_left, 'top':new_top});
    $('#div_myswapen').slideDown('slow');
  }
  
  function replacebuyer(val)
  {
    $('#a_buyer').html(val);
  }
  
  function showLoginPopup()
  {
    var pos = $('#my_swapen').position();
    var nleft = parseInt(pos.left)-130;
    var ntop = parseInt(pos.top)+28;
    $('#login_box').css({'left': nleft, 'top':ntop});
    $('#login_box').fadeIn('slow');
  }
  var gflag=0;
  function showBuyerPopup()
  {
    //alert('id'+id+'gflag'+gflag);
    if(gflag==0)
    {
 	var pos = $('#a_buyer').position();
	var nleft = parseInt(pos.left);
	var ntop = parseInt(pos.top)+20;
	$('#buyer_box').css({'left': nleft, 'top':ntop});
	$('#buyer_box').fadeIn('1000');
	gflag =1;
    
    }
  }
  
  function showBuyermenu()
  {
    var pos = $('#a_menu').position();
    var nleft = parseInt(pos.left);
    var ntop = parseInt(pos.top)+30;
    $('#menu_box').css({'left': nleft, 'top':ntop});
    $('#menu_box').fadeIn('1000');
  }
  
  function validateLogin()
  {
   // alert('hi');
    var username = $('#username').val();
    var password = $('#password').val();
    $('#login_error').html('');
    if(username=='' || password=='')
    {
      alert('Please enter username and password');
    }
    else
    {
      var url = "<?php echo $base_url;?>ajax_signin.php";
      $.post(url,
      { 'username': username, 'password':password},
      function(data)
      {
		if(data=='Your account is on hold, please contact us for more information')
		  $('#login_error').html(data);
		else if(data=='Your Account has been placed on the inactive list, please contact Swapen Support')
		  $('#login_error').html(data);
		else if(data=='Invalid user name and password.')
		  $('#login_error').html(data);
		else if(data=='')
		  window.location='index.php';
		else
		  window.location='index.php?'+data;
      },
      'html'
      );
    }
  }
  
  function tracking(section)
  {
  
    var http;
    if (window.XMLHttpRequest) {
      http = new XMLHttpRequest();	
    }
    else if (window.ActiveXObject)
    {
      http = new ActiveXObject("Microsoft.XMLHTTP");
    }
  
    http.open('GET',  'ntracking.php?section='+section);
    http.onreadystatechange = function () {
      if(http.readyState == 4){
	var response = http.responseText;
      }
    }
    http.send(null);
  }
   
  function show_howswapen()
      {
		var pos = $('#how_swapen').position();
		var nleft = parseInt(pos.left)-144;
		var ntop = parseInt(pos.top)+15;
		$('#more_infohow').css({'left': nleft, 'top':ntop});
		$('#more_infohow').fadeIn('slow');
      }
   </script>

<!--header start -->
<div class="header">
<?php
if(($_SESSION['viewcart']!="") && !empty($_SESSION['user_id_sess']))
{
    $sqlCartCount="select * from tempcart where user_id='".$_SESSION['user_id_sess']."'";
}
else
{
    $sqlCartCount="select * from tempcart where session_id='".$sessid."'";
}
$resCartCount=mysql_query($sqlCartCount);
$nrowCart=mysql_num_rows($resCartCount);

if($_SESSION['user_id_sess']!="") {
  $sellflag=0;
  $sqluser="select tbl_businesstype.sellflag from tbl_users,tbl_businesstype where user_id='".$_SESSION['user_id_sess']."' and status='1' and tbl_users.bus_id=tbl_businesstype.bus_id";
  $resuser=mysql_query($sqluser);
  $Rowuser=mysql_fetch_array($resuser);
  $sellflag=$Rowuser['sellflag'];
  $sqlMsg="select * from tbl_messages where recieverid='".$_SESSION['user_id_sess']."' and status='1'";
  $resMsg=mysql_query($sqlMsg);
  $nRowmsg=mysql_num_rows($resMsg);
  
  //echo "Welcome! ".ucfirst($_SESSION['user_name']);
  //echo "&nbsp; <a href='index.php?signout' class='login'>Sign out</a> <a href='index.php?inbox' class='inn'><img src=images/message-icon.png border=0 title=Inbox>(".$nRowmsg.")</a>"; 
  ?>
<div class="loggedin">
<div class="login-bg"><span class="white fnt-11">Welcome<br />back</span>
	<p class="white bold fnt-12"><?php echo ucfirst($_SESSION['user_name']);?></p>
	</div>
	<div class="clear" style="height:0px; line-height:0px;"></div>
	<a href="#" class="notu">not you?</a><a href="index.php?signout" class="logout">Logout</a><a href="javascript:void(0);" onclick="show_helpBox();" class="help bold" id="help_a">help</a>
	
</div>

<?php 
} else {
?>
<div class="top-left"><a href="index.php?signin#sign" onclick="return tracking('Sign In');" class="login"><img src="images/butt-login.jpg" alt="" /></a><a href="index.php?signup#reg" onclick="return tracking('Register');" class="register"><img src="images/butt-register.jpg" alt="" /></a><a href="javascript:void(0);" onclick="show_helpBox();" class="help bold" id="help_a">help</a></div>
<?php } ?>

<div id="help_drop_down" class="help_popup">
  <span onclick="$('#help_drop_down').slideUp('slow');"><strong>x</strong></span>
  <ul>
  <li><a href="<?php echo $base_url;?>index.php?about#abt">About</a></li>
  <li><a href="<?php echo $base_url;?>index.php?contact#cnt">Contact us</a></li>
  <li><a href="<?php echo $base_url;?>index.php?faq#faq">FAQ</a></li>
  <li><a href="<?php echo $base_url;?>index.php?agreement#agr">Agreements</a></li>
  <li><a href="<?php echo $base_url;?>index.php?resolution#rsl">Resolution Center</a></li>
  <li><a href="<?php echo $base_url;?>index.php?policy#plcy">Privacy Policy</a></li>
  </ul>
</div>
<?php if($_SESSION['user_status']!="3")
{
	if($sellflag!=1)
	{
?>
<div class="top-right"><a href="index.php?products#prd" onclick="return tracking('Buy');" class="buy bold" <?php if(isset($_GET['products'])) { ?>id="selected"<?php } ?>>Buy</a>
<?php } ?>
<?php
	if($sellflag!=1)
	{
		if($_SESSION['user_type_sess']==2 || $_SESSION['user_type_sess']=='')
		{
			 $sell_link = "index.php?sell_page#sellp";
		}
		else 
		{
			 $sell_link = "index.php?sell&by=seller#sprd";
		}
		
		if($_SESSION['user_type_sess']==5)
		{
			  $sell_link = "index.php?import=1";
		}
?>
<a href="<?php if($_SESSION['user_id_sess']!="") { echo $sell_link; } else { ?>index.php?sell_page#sellp<?php } ?>" onclick="return tracking('Sell');" class="sell bold" <?php if(isset($_GET['sell_page']) || $_GET['sell'] || $_GET['import']=="1") { ?>id="selected"<?php } ?>>Sell</a>
<?php } ?>
<a href="index.php?post#pst" class="post bold" onclick="return tracking('Post');" <?php if(isset($_GET['post'])) { ?>id="selected" <?php } ?>>Post</a>
<?php } ?>
<?php //if($_SESSION['user_id_sess']!="")	{ ?>
<a href="javascript:void(0);" onclick="show_mySwapenBox();" class="myswap bold" id="my_swapen">My Swapen</a>
<?php //} else { ?>
<!--<a href="index.php?signin" class="myswap bold" onclick="return tracking('Sign In');" id="my_swapen">My Swapen</a>-->
<?php //} ?>
</div>
<div id="div_myswapen" class="help_popup">
  <span onclick="$('#div_myswapen').slideUp('slow');"><strong>x</strong></span>
  <ul>
  <li><a href="<?php echo $base_url;?>index.php?mySwapen#mswapen">mySwapen</a></li>
  <li><a href="<?php echo $base_url;?>index.php?profile">myAccount</a></li>
  <li><a href="<?php echo $base_url;?>index.php?inbox">myMessages</a></li>
  </ul>
</div>

<div class="top-mid"><span class="orange">Exlusive features only offered on swapen<br />Have you products sold for you<br />Sell products for others<br />many more...</span></div>

<?php if($_SESSION['user_id_sess']!="") { ?>
<div class="inbox"><a href="index.php?inbox" class="inn">inbox (<?php echo $nRowmsg?>)</a><a href="index.php?cart#crt" class="scart">Shopping Cart (<?php echo $nrowCart;?>)</a></div>
<?php } else { ?>
<div class="inbox" style="width:100px;"><a href="index.php?cart#crt" class="scart">Shopping Cart (0)</a></div>
<?php } ?>

<div class="clear logo"><a href="index.php"></a></div>

<form name="formSearchAll" id="formSearchAll" method="post" action="">
<input type="text" name="sg" id="sg" value="all">
<input type="hidden" name="spage" id="spage" value="<?php echo $searchpage; ?>">
<?php
//$lo = $oo = $sm = $sb = $sa = '';
//$val="Search All";
//
//if($_GET['sg']=='local'){ $lo = 'class="current"'; $val="Local Only";}
//else if($_GET['sg']=='online'){ $oo = 'class="current"';$val="Online Only";}
//else if($_GET['sg']=='merchant'){ $sm = 'class="current"';$val="Search Merchant";}
//else if($_GET['sg']=='buyer') {$sb = 'class="current"';$val="Search Buyer";}
//else $sa = 'class="current"';
?>
<div class="search"><a href="javascript:void(0);" class="selected" id="srch_all" onclick="click_search_all();" onmouseover="mouseover_search_all();" onmouseout="mouseout_to_all_search();">search all</a><div class="vline"></div><a href="javascript:void(0);" id="srch_local" onclick="click_search_local();" onmouseover="mouseover_search_local();" onmouseout="mouseout_to_all_search();">search local</a><div class="vline"></div><a href="javascript:void(0);" id="srch_online" onclick="click_search_online();" onmouseover="mouseover_search_online();" onmouseout="mouseout_to_all_search();">search online</a><div class="vline"></div>
<?php if($_SESSION['user_type_sess']=="5") { ?>
<a href="javascript:void(0);" id="srch_merchant" onclick="click_search_merchant();" onmouseover="mouseover_search_merchant();" onmouseout="mouseout_to_all_search();" class="forbuyer" style="width:120px">Search for Merchant</a>
<?php }	else { ?>
<a href="javascript:void(0);" id="srch_buyer" onclick="click_search_buyer();" onmouseover="mouseover_search_buyer();" onmouseout="mouseout_to_all_search();" class="forbuyer" style="width:120px">Search for Buyer</a><img src="images/arrow.jpg" align="absmiddle" style="margin:9px 0px 0px 3px;" alt="" />
<?php } ?>	
<br />
<div class="field"><input type="input" id="div_input_search" class="input" name="key" value="search all" onfocus="this.select(); if(this.value=='search all') this.value=''" onblur="if(this.value=='') this.value='search all'" /></div><div class="forsale"><select style="width:84px"><option>For Sale</option><option>Jobs</option><option>Rents</option><option>Real Estate</option><option>Classifieds</option></select></div><input type="image" value="" class="submit"  src="images/butt-search.jpg" alt="" onclick="funSearchAll()" />
<p class="clear" id="sel_text" style="display:none">search all</p>
<p class="clear" id="div_click_search">search all - "searches through local and online listing of products<br />advance search - modifies your area and price range"</p>
<p class="clear" id="div_click_search2" style="display:none;"></p>
</div>
</form>

<div class="adv-search"><p class="text">los angeles, ca<br /><a href="#" class="ads">advanced search</a></p><img src="images/icon-adsearch.jpg" class="icon" alt="" /></div>


<div class="why-use">
  <p class="white"><?php if($_SESSION['user_id_sess']!="") { ?>Don't forget<?php } else { ?>Why use Swapen.com?<?php } ?></p>
</div>


<div class="menu"><?php if($_SESSION['user_id_sess']!="") { ?><a href="#">sell products for others</a><a href="#">referral commisison</a><a href="#">local pick-up verification</a><a href="#">verified merchants</a><a href="#">all products shipped from US</a><?php } else { ?><a href="#">free to join</a><a href="#">no listing fees</a><a href="#">free store</a><a href="#">local pick-up</a><a href="#">verified merchats</a><a href="#">all products shipped from U.S.</a><?php } ?></div>

<?php if($_SESSION['user_id_sess']=="") { ?>
<div class="learnmore"><a href="<?php echo $base_url;?>index.php?signup#reg" class="bold">Learn more</a></div>
<?php } ?>

<div style=" display: none; width: 400px; font-weight:bold; padding:10px; background-color:#cccccc; opacity:1;" class="user_popup" id="more_infohow">
	<span style="float:left; width:100%; text-align:right; margin-bottom:5px;"><label style="cursor:pointer;" onclick="$('#more_infohow').fadeOut('slow');"><strong>x</strong></label></span>
	<span style="float:left; width:100%; margin-bottom:10px;" id="desc_info"><strong>Buyers will search for products they are interested in, chat, message, negotiate with sellers, plus refer members and get paid.<br/><br/>

 Sellers have the option to sell their own items, have their items sold by someone else, sell on behalf of others, all at no charge, plus refer members and get paid.<br/><br/>

Merchants can create an entire inventory of products you want to sell for free, and best of all the sellers will pick them up to sell on your behalf, plus refer members and get paid<br/><br/>

Wholesalers can create an entire inventory within minutes by using our upload data sheet feature, no startup fees and no listing fees. Plus merchants will have exclusive access to your store at no cost, so the potential is endless.</strong></span>
</div>

</div><!--header end -->

<script type="text/javascript">

  function show_cats(a)
  {
    $('#catBox').html('<div style="text-align:center; width:100%; float:left; padding:30px 0px 30px 0px"><img src="<?php echo $base_url;?>images/spinningLoader.gif" align="absmiddle"  /><div>').show();
    var pos = $('#menulinks').position();
    var nleft = parseInt(pos.left) + 11;
    var ntop = pos.top;
    
    $('#catBox').css({'left':nleft,'top':ntop});
   
    $('#cat_a'+a).attr('class','current');
    
    $('#for_sale').attr('class','');
    $('#jobs').attr('class','');
    $('#real_esate').attr('class','');
    $('#rent').attr('class','');
    $('#classifieds').attr('class','');
    
    var url = "<?php echo $base_url;?>ajax_category.php";
    $.post(url,
    { 'id': a},
    function(data)
    {
      if(data!='')
      $('#catBox').html(data);
      
      if(a==1)
	$('#for_sale').attr('class','current');
      else if(a==2)
	$('#jobs').attr('class','current');
      else if(a==3)
	$('#real_esate').attr('class','current');
      else if(a==4)
	$('#rent').attr('class','current');
      else if(a==5)
	$('#classifieds').attr('class','current');
    },
    'html'
    );
    
  }
  
  function set_form_fields(type)
  {
    //alert(type);
    $('#a_all').attr('class','');
    $('#a_local').attr('class','');
    $('#a_online').attr('class','');
    $('#a_buyer').attr('class','');
    $('#a_merchant').attr('class','');
    if(type=='all')
    {
      $('#sg').val('all');
      $('#catId').attr('disabled','');
      $('#state').attr('disabled','');
      $('#city').attr('disabled','');
      
      $('#a_all').attr('class','current');
      $('#searchBtn').val('Search All');
    }
    else if(type=='local')
    {
      $('#sg').val('local');
      $('#catId').attr('disabled','disabled');
      $('#state').attr('disabled','');
      $('#city').attr('disabled','');
      
      $('#a_local').attr('class','current');
      
      $('#searchBtn').val('Local Only');
    }
    else if(type=='online')
    {
      $('#sg').val('online');
      $('#catId').attr('disabled','disabled');
      $('#state').attr('disabled','disabled');
      $('#city').attr('disabled','disabled');
      
      $('#a_online').attr('class','current');
      $('#searchBtn').val('Online Only');
    }
    else if(type=='buyer')
    {
      $('#sg').val('<?php if($_SESSION['user_type_sess']=="5") { ?>merchant<?php } else {?>buyer<?php }?>');
      $('#catId').attr('disabled','disabled');
      $('#state').attr('disabled','');
      $('#city').attr('disabled','');
      
      $('#a_buyer').attr('class','current');
      $('#searchBtn').val('Search Buyer');
    }
    else if(type=='merchant')
    {
      $('#sg').val('<?php if($_SESSION['user_type_sess']=="5") { ?>merchant<?php } else {?>buyer<?php }?>');
      $('#catId').attr('disabled','disabled');
      $('#state').attr('disabled','');
      $('#city').attr('disabled','');
      
      $('#a_merchant').attr('class','current');
      $('#searchBtn').val('Search Merchant');
    }
    else if(type=='Employee')
    {
      $('#sg').val('<?php if($_SESSION['user_type_sess']=="5") { ?>merchant<?php } else {?>buyer<?php }?>');
      $('#catId').attr('disabled','disabled');
      $('#state').attr('disabled','');
      $('#city').attr('disabled','');
      
      $('#a_buyer').attr('class','current');
      $('#searchBtn').val('Search Employee');
    }
    else if(type=='Real Estate')
    {
      $('#sg').val('<?php if($_SESSION['user_type_sess']=="5") { ?>merchant<?php } else {?>buyer<?php }?>');
      $('#catId').attr('disabled','disabled');
      $('#state').attr('disabled','');
      $('#city').attr('disabled','');
      
      $('#a_buyer').attr('class','current');
      $('#searchBtn').val('Search Real Estate');
    }
    else if(type=='Classifieds')
    {
      $('#sg').val('<?php if($_SESSION['user_type_sess']=="5") { ?>merchant<?php } else {?>buyer<?php }?>');
      $('#catId').attr('disabled','disabled');
      $('#state').attr('disabled','');
      $('#city').attr('disabled','');
      
      $('#a_buyer').attr('class','current');
      $('#searchBtn').val('Search Classifieds');
    }
    
  }
  
  function funSearchAll() {	
  
    var frm=document.getElementById('formSearchAll');
    
    var spage 	=	$('#spage').val();
    var sg	= 	$('#sg').val();
	var key=frm.key.value;
    if(spage=='1') {
	      srchPage = "";
      } else {
	      srchPage = "";
      }
    //var jobp=document.getElementById('catId').value;
    //check search page
    //if(jobp>1 && jobp<6){
    //frm.action="index.php?srchPost&catId="+jobp;
	frm.action="index.php?"+srchPage+"srch&sg="+sg+"&key="+key;
    frm.submit();
    /*}
    else {
    
      if(spage=='1') {
	      srchPage = "";
      } else {
	      srchPage = "";
      }
      
      var sg=frm.sg.value; 
      var key=frm.key.value;
      var pf=frm.priceFrom.value; 
      var pt=frm.priceTo.value;
      if(sg=='buyer' || sg=='merchant'){
	var st=frm.state.value;  
	var ct=frm.city.value;
	frm.action="index.php?srchBuyer&sg="+sg+"&key="+key+"&st="+st+"&cty="+ct+"&pf="+pf+"&pt="+pt; 	
      }
      else if(sg!='online')
      {
	var st=frm.state.value;  
	var ct=frm.city.value;
	 frm.action="index.php?"+srchPage+"srch&sg="+sg+"&key="+key+"&st="+st+"&cty="+ct+"&pf="+pf+"&pt="+pt;
      }
      else
	frm.action="index.php?"+srchPage+"srch&sg="+sg+"&key="+key+"&pf="+pf+"&pt="+pt;
	
	frm.submit();
    }*/
  }
  
  function showHideBox()
  {
      var divstyle = new String();
      divstyle = document.getElementById("tblPrice").style.visibility;
	      if(document.getElementById("catId").value=='2')
	      {
                 document.getElementById("price1").innerHTML="Salary range"
             }
	     else
	     {
	        document.getElementById("price1").innerHTML="Price rannge"
	     }
      
  }
</script>